<template>
    <div class="gridList">
        <scroll-view scroll-x class="my-scroll-view">
            <div class="item" v-for="(item, index) in list" :key="index" @click="handleView(item)">
                <div class="image">
                    <div class="vip" v-if="item.is_vip=='1'">
                        <image class="img" src="/static/img/vip01.svg" mode="widthFix"></image>
                    </div>
                    <div class="count-text">
                        <div class="count" v-if="item.score">{{item.score}}</div>
                        <div class="text" v-if="item.teli&&item.teli !='يوق'">{{item.teli}}</div>
                    </div>
                    <div class="qisim" v-if="isShowQisim&&item.qisim>='2'">
                        <div class="white">{{item.qisim}}</div>
                        <div class="white margin-lr-xs">/</div>
                        <div class="yellow tip">
                            <div>قىسىم</div>
                            <div>-{{item.qisim_count}}</div>
                        </div>
                    </div>

                    <image class="img" :src="item.image" mode="aspectFill"></image>
                </div>
                <div class="text">
                    <div class="name">{{item.title}}</div>
                    <div class="desc" v-if="isShowDesc">
                        <div v-if="item.rayonName">{{item.rayonName}}</div>
                        <div class="center">/</div>
                        <div v-if="item.category_name">{{item.category_name}}</div>
                        <div class="center">/</div>
                        <div v-if="item.yilName">{{item.yilName}}</div>
                    </div>
                </div>
            </div>
        </scroll-view>
    </div>
</template>

<script>
    import {
        getRoute
    } from '@/scripts/compatible/pageOptions.js'
    export default {
        props: {
            list: {
                type: Array,
                require: true,
            },
            isShowDesc: {
                type: Boolean,
                default: () => true,
            },
            isShowQisim: {
                type: Boolean,
                default: () => true,
            },
        },
        data() {
            return {

            }
        },
        methods: {
            handleView(item) {
                // console.log(item);
                const route = getRoute()
                const path = '/pages/view/index'
                if (path == route) {
                    uni.redirectTo({
                        url: `${path}?id=${item.id}`
                    })
                } else {
                    uni.navigateTo({
                        url: `${path}?id=${item.id}`
                    })
                }
            },

        },
    }
</script>

<style lang="scss" scoped>
    .gridList {
        // display: flex;
        // flex-wrap: wrap;
        // justify-content: space-evenly;
        // flex-direction: row-reverse;

        .my-scroll-view {
            white-space: nowrap;
            overflow: hidden;
            direction: rtl;
        }

        .item {
            width: calc((100% - 30px) / 3);
            margin: 0 15px 0 0;
            display: inline-block;

            &:first-of-type {
                margin-right: 0;
            }

            .image {
                height: 152px;
                position: relative;
                overflow: hidden;
                border-radius: 8px;

                .img {
                    display: block;
                    width: 100%;
                    height: 100%;
                }
            }

            .vip {
                width: 30px;
                position: absolute;
                left: 5px;
                top: -5px;
                z-index: 1;

                .img {
                    display: block;
                    width: 100%;
                }
            }

            .count-text {
                height: 20px;
                border-radius: 10px;
                overflow: hidden;
                display: flex;
                align-items: center;
                width: max-content;
                position: absolute;
                top: 5px;
                right: 5px;
                z-index: 1;

                .count {
                    background-color: #333333;
                    color: #fff;
                    width: max-content;
                    padding: 0 6px;
                    font-size: 12px;
                }

                .text {
                    color: #fff;
                    background-color: #0081ff;
                    width: max-content;
                    padding: 0 6px;
                    font-size: 12px;
                }
            }

            .qisim {
                position: absolute;
                left: 0;
                right: 0;
                bottom: 0;
                height: 32px;
                display: flex;
                align-items: center;
                justify-content: center;
                flex-direction: row-reverse;
                z-index: 1;
                background-image: linear-gradient(transparent, rgba(0, 0, 0, .6));

                .tip {
                    display: flex;
                }

                .white {
                    color: #fff;
                }

                .yellow {
                    color: #fbbd08;
                }

                .margin-lr-xs {
                    margin: 0 4px;
                }
            }

            .text {
                font-size: 12px;
                white-space: nowrap;
                text-align: center;
                transform: scaleX(.8);
                overflow: hidden;

                .name {
                    color: #000;
                }

                .desc {
                    display: flex;
                    flex-direction: row-reverse;
                    justify-content: center;
                    color: #999;

                    .center {
                        margin: 0 2px;
                    }
                }
            }
        }
    }
</style>